@echo off
setlocal enabledelayedexpansion

REM 设置编译器
set COMPILER=g++

REM 设置源代码和头文件目录
set SRC_DIR=src
set INCLUDE_DIR=head

REM 设置输出文件名
set OUTPUT_DLL=MyLibrary.dll

REM 设置编译选项
set CXXFLAGS_DLL=-Wall -Wextra -std=c++11 -shared

REM 输出变量的值以进行调试
echo Compiler: %COMPILER%
echo Source directory: %SRC_DIR%
echo Include directory: %INCLUDE_DIR%
echo DLL output file: %OUTPUT_DLL%
echo Compiler flags for DLL: %CXXFLAGS_DLL%

REM 查找所有的源文件
set SOURCES_DLL=
for %%f in (%SRC_DIR%\*.cpp) do (
    set SOURCES_DLL=!SOURCES_DLL! %%f
)

REM 输出找到的源文件列表
echo DLL source files: %SOURCES_DLL%

REM 编译 DLL
%COMPILER% %CXXFLAGS_DLL% -I %INCLUDE_DIR% %SOURCES_DLL% -o %OUTPUT_DLL%

REM 检查编译是否成功
if %errorlevel% neq 0 (
    echo DLL Compilation failed!
    pause
    exit /b
)

echo DLL Compilation succeeded! Output file is %OUTPUT_DLL%
pause
